/*
 * Executor.h
 *
 *  Created on: Jun 15, 2010
 *      Author: administrator
 */

#ifndef EXECUTOR_H_
#define EXECUTOR_H_
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "types/query.h"
#include "types/hash.h"
#include "types/record.h"
#include "modules/record_mgr.h"
using namespace std;

struct table_info{
	string tableName;
	int num_attr;
	vector<string> attributes;
};

struct table_index_info{
	string tableName;
	vector<string> indexName;
	vector<string> attributeName;
	vector<bool> index_duplicate;
};

class Executor {
public:
	FILE *outCatalogFile;
	Executor();
	virtual ~Executor();
	void write(SQL *cat);
	void writeIndex(SQL *sql);
	void read();
	void readIndex();
	bool validateCreateTable(SQL *sql);
	bool validateCreateIndex(SQL *sql);
	bool validateInsert(SQL *sql);
	bool validateSelect(SQL *sql);
	bool validateWhere(table_info *table, SQL *sql);
	void printCatalog();
	void printRecords(vector<Record> &records, table_info *table, SQL *sql);
	bool isequal(string s1,string s2);
};

#endif /* EXECUTOR_H_ */
